package top.csmcool.musicapi.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.csmcool.musicapi.model.api.navidrome.SongCollection;
import top.csmcool.musicapi.model.playlist.*;
import top.csmcool.musicapi.model.result.Request;
import top.csmcool.musicapi.model.result.Result;
import top.csmcool.musicapi.service.MusicService;

import java.util.List;

/**
 * @Description
 * @Author shizhe
 * @Date 2025/1/27
 */

@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
@CrossOrigin(origins = "*")
public class MusicController {

    private final MusicService musicService;

    @PostMapping("/tracks")
    public Result<List<PlayListMusicInfo>> tracks(@RequestBody Request<TracksRequest> requestRequest) {
        return musicService.getTracks(requestRequest);
    }

    @PostMapping("/lyric")
    public Result<List<LyricInfo>> lyric(@RequestBody Request<LyricRequest> requestRequest) {
        return musicService.getLyric(requestRequest);
    }

    @PostMapping("/playlist")
    public Result<List<SongCollection>> playlist(@RequestBody Request<PlayListRequest> requestRequest) {
        return musicService.playlist(requestRequest);
    }

    @PostMapping("/search")
    public Result<List<PlayListMusicInfo>> search(@RequestBody Request<SearchRequest> requestRequest) {
        return musicService.search(requestRequest);
    }

    @PostMapping("/personalizedPlaylist")
    public Result<List<SongCollection>> personalizedPlaylist(@RequestBody Request<PlayListRequest> requestRequest) {
        return musicService.personalizedPlaylist(requestRequest);
    }

    @PostMapping("/songUrl")
    public Result<SongInfo> getSongUrl(@RequestBody Request<SongUrlRequest> requestRequest) {
        return musicService.getSongUrl(requestRequest);
    }
}
